﻿using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using Sharp.Domain.PlatformBoundedContext.OrgModule.Aggregates;

namespace Sharp.Domain.PlatformBoundedContext.ModelConfigurations
{
    public partial class OrgForBusinessListConfiguration
        : EntityTypeConfiguration<OrgForBusinessList>
    {
        public OrgForBusinessListConfiguration()
        { 
            // keys
            HasKey(t => t.Id);

            // Properties
            Property(t => t.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);
            Property(t => t.OrgForBusinessId)
                .IsRequired();
            Property(t => t.OrgId)
                .IsRequired();
            Property(t => t.ParentId)
                .IsOptional();
            Property(t => t.OrderIndex)
                .IsOptional();

            HasRequired(t => t.OrgForBusiness)
                .WithMany(t => t.OrgForBusinessList)
                .HasForeignKey(d => d.OrgForBusinessId);

            HasRequired(t => t.Org)
                .WithMany(t => t.OrgForBusinessList)
                .HasForeignKey(d => d.OrgId);


        }
    }
}
